# Maintainer: Christoph Reiter <reiter.christoph@gmail.com>

_realname=mutagen
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=1.47.0
pkgrel=3
pkgdesc="An audio metadata tag reader and writer"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://github.com/quodlibet/mutagen'
msys2_references=(
  'purl: pkg:pypi/mutagen'
)
license=('spdx:GPL-2.0-or-later')
depends=("${MINGW_PACKAGE_PREFIX}-python")
makedepends=(
  "${MINGW_PACKAGE_PREFIX}-python-build"
  "${MINGW_PACKAGE_PREFIX}-python-installer"
  "${MINGW_PACKAGE_PREFIX}-python-setuptools"
)
options=('!strip')
source=("https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realname}-${pkgver}.tar.gz")
sha256sums=('719fadef0a978c31b4cf3c956261b3c58b6948b32023078a2117b1de09f0fc99')

build() {
  cd "${srcdir}"
  cp -r "${_realname}-${pkgver}" "python-build-${MSYSTEM}" && cd "python-build-${MSYSTEM}"

  ${MINGW_PREFIX}/bin/python -m build --wheel --skip-dependency-check --no-isolation
}

package() {
  cd "${srcdir}/python-build-${MSYSTEM}"

  MSYS2_ARG_CONV_EXCL="--prefix=" \
    ${MINGW_PREFIX}/bin/python -m installer --prefix=${MINGW_PREFIX} \
    --destdir="${pkgdir}" dist/*.whl

  install -Dm644 COPYING "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/COPYING"
}
